home *** CD-ROM | disk | FTP | other *** search
/ PCMania 24 / PCMania CD24.nrg / mmedia / music / mp / cdec.doc next >
Text File  |  1994-09-07  |  13KB  |  484 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                               C D E CC D E C
  14.  
  15.  
  16.  
  17.             C Declaration to English Translator Program            C Declaration to English Translator Program
  18.  
  19.                               for the
  20.  
  21.                      I.B.M PC/AT and Compatibles
  22.  
  23.  
  24.  
  25.                           by John S. Smith
  26.                            c/o 'Rosemont'
  27.                             Hawthorn Rd
  28.                               Beaufort
  29.                              Ebbw Vale
  30.                                Gwent
  31.                            United Kingdom
  32.  
  33.  
  34.  
  35.  
  36.  
  37.                Copyright (C) 1989-90 by John S. Smith               Copyright (C) 1989-90 by John S. Smith
  38.                         All Rights Reserved___ ______ ________
  39.  
  40.             This document last revised 21st October 1990
  41.  
  42.  
  43.  
  44.         The CDEC diskette containing a copy of this document
  45.         is distributed under the Shareware scheme and may be
  46.            freely copied provided that none of the files
  47.          thereon are modified in any way. Printed copies of
  48.           the documentation may not be copied without the
  49.               express written permission of the author
  50.         CDEC Guide                         For C Programmers
  51.  
  52.  
  53.  
  54.         1  Introduction        1  Introduction
  55.  
  56.  
  57.         CDEC is a program  that  translates  declarations in
  58.         the C programming language into an English phrase.
  59.  
  60.         CDEC is particularly useful for checking the meaning
  61.         of  complex  declarations  or  even  not-so  complex
  62.         declarations when one is unsure of the precedence of
  63.         operators. For example the difference between:
  64.  
  65.         char * msg[MAX_NUM];
  66.  
  67.         and
  68.  
  69.         char (* msg)[MAX_NUM];
  70.  
  71.         is easily and quickly found with CDEC.
  72.  
  73.         Also,  when  trying to understand  code  written  by
  74.         others,   declarations   can   be   a   particularly
  75.         troublesome and time-consuming area. CDEC is a great
  76.         help with this sort of task.
  77.  
  78.         Another  useful area is when one  wishes  to  use  a
  79.         particularly  complex declaration as the problem  at
  80.         hand  dictates  it,  yet  how  can you be  sure  the
  81.         declaration  is right? Your compiler may compile  it
  82.         ok but does the declaration mean what you want it to
  83.         mean?  Just  enter  it  to  CDEC  and  get a  second
  84.         opinion.
  85.  
  86.         Declarations  get even more difficult to  understand
  87.         when the "far" and  "near"  keywords  that  are used
  88.         with   many   compilers   are  involved.  Just  what
  89.         associates with what? Well,  even  though  "far" and
  90.         "near" are not part of the  C  programming language,
  91.         CDEC includes them as they are in such common usage.
  92.         There is also support for the "const" keyword.
  93.  
  94.  
  95.         CDEC runs on all PC compatible machines and needs no
  96.         special  hardware  or displays. CDEC  uses  a  plain
  97.         scrolling display rather than  pop-up  menus  etc to
  98.         minimise  code size and thus minimises loading  time
  99.         from disc. It is possible  to  start  CDEC,  check a
  100.         declaration  and return to DOS before many  programs
  101.         could even load! (Well I think so anyway).
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.         A Shareware Program       page 2       October, 1990
  112.         CDEC Guide                         For C Programmers
  113.  
  114.  
  115.  
  116.         2  Installation and Test        2  Installation and Test
  117.  
  118.  
  119.         CDEC consists of  just one executable file CDEC.EXE.
  120.         Copy this file  to  any  directory  in  your current
  121.         path.
  122.  
  123.  
  124.         3  Starting CDEC        3  Starting CDEC
  125.  
  126.  
  127.         Type:
  128.                 CDEC
  129.         or
  130.                 CDEC -x
  131.         In the  latter  case  CDEC  attempts  to  give extra
  132.         information   about   certain    declaration   where
  133.         possible.  In   particular   declarations  involving
  134.         "const"  and  the  common  compiler  extensions  for
  135.         segmented addressing  "far"  and  "near"  have extra
  136.         information.
  137.  
  138.  
  139.         4  Usage        4  Usage
  140.  
  141.  
  142.         CDEC  prompts  for   a  declaration.  Type  in  your
  143.         declaration and press the Enter or return  key. CDEC
  144.         will  produce  an  English  translation on screen if
  145.         possible. If there is an error, the  probable reason
  146.         is displayed followed by a new prompt for you to try
  147.         again.
  148.  
  149.         The  functions  keys  provide  access to much useful
  150.         information.
  151.  
  152.         The "?" key aborts the current declaration   without
  153.         leaving the program.
  154.  
  155.         The Esc key exits CDEC.
  156.  
  157.         If you wish to save  the generated output to a file,
  158.         use the DOS redirection feature and start  CDEC like
  159.         this:
  160.  
  161.                 CDEC > myfile
  162.  
  163.         CDEC will place  the  translated  output  in  a file
  164.         called "myfile". This redirected output  is detected
  165.         by  CDEC  and  the  output  will  be  surrounded  by
  166.         standard C comment delimiters /* comment */  so that
  167.         "myfile" can be included in your  source  code later
  168.         if  you  wish.  To end this process,  press  Esc  as
  169.         before. If any  declaration  is  in  error  then the
  170.  
  171.  
  172.  
  173.         A Shareware Program       page 3       October, 1990
  174.         CDEC Guide                         For C Programmers
  175.  
  176.  
  177.  
  178.         error message will always appear on  the  screen and
  179.         never be sent to file.
  180.  
  181.         You may append a comment  to  any  CDEC  input line.
  182.         Such a comment is introduced by two slashes (//)
  183.  
  184.         eg      char buf[10]; // store name
  185.  
  186.         This comment will also be stored  in  any redirected
  187.         output file.
  188.  
  189.         It is possible to start CDEC with  redirected output
  190.         AND with the extra information option turned on.
  191.  
  192.         eg      CDEC -x > myfile
  193.  
  194.         In this case, any  extra  information  goes  only to
  195.         file (not to screen) but the translated  output goes
  196.         to screen AND file.
  197.  
  198.         CDEC will  also accept a list of declarations from a
  199.         file as redirected input:
  200.  
  201.         eg      CDEC <list
  202.  
  203.         Where  the  file  "list"  contains  a   list   of  C
  204.         declaration to be translated.
  205.  
  206.         It is possible to use  redirected  input  and output
  207.         together:
  208.  
  209.         eg      CDEC < list > myfile
  210.  
  211.         or
  212.  
  213.                 CDEC -x < list > myfile
  214.  
  215.  
  216.         5  Commom omissions and additional information        5  Commom omissions and additional information
  217.  
  218.  
  219.         Failure to end the declaration with a semicolon ";".
  220.         ALL declaration require this.
  221.  
  222.         CDEC  can translate declaration than are beyond  the
  223.         power of current compilers to accept!  (At  least as
  224.         far  as  I  am  aware).  Such  declarations  are not
  225.         incorrect  as  such  but  it  is   just   that  such
  226.         declarations   are   maybe  too   expensive   and/or
  227.         difficult (or unnecessary?) in computing terms to be
  228.         implemented.  Maybe such declarations will never  be
  229.         implemented  but CDEC translates them now. This  has
  230.         advantages  for  educational   purposes   at  least.
  231.         Typical of such declarations are:
  232.  
  233.  
  234.  
  235.         A Shareware Program       page 4       October, 1990
  236.         CDEC Guide                         For C Programmers
  237.  
  238.  
  239.  
  240.         int alpha()();  int beta()[];  int gamma[]();
  241.  
  242.         Input these  to CDEC to see what they mean. Pointers
  243.         to such items ARE allowed.
  244.  
  245.         C declarations, particularly  structures  and unions
  246.         are usually written on more than one line:
  247.  
  248.         eg      struct tag {
  249.                         int count;
  250.                         char * chr;
  251.                         } struct_name;
  252.  
  253.         However this format is  only  for  stylistic reasons
  254.         and such a  declaration  is just as valid if written
  255.         on a single line, such as
  256.  
  257.         struct tag { int count; char * chr; } struct_name;
  258.  
  259.         CDEC requires the single line version as translation
  260.         starts  as  soon  as  the  Enter  or  return key  is
  261.         pressed.  This  does  not  limit  the  length  of  a
  262.         declaration and  a  very  long  declaration  may  be
  263.         greater than one screen  line  --  just  keep typing
  264.         when the cursor gets to the right hand  side  of the
  265.         screen  but  don't  press  return  until  the  whole
  266.         declaration is entered.
  267.  
  268.         CDEC  translates  declarations  involving  functions
  269.         arrays  pointers  "primitive"  data types aggregates
  270.         data types  such as struct and unions. Also there is
  271.         extended support for the  "far"  "near"  and "const"
  272.         keywords.  Note  that  CDEC  identifies but does not
  273.         parse  parameter lists  for  functions  and  behaves
  274.         similarly  for struct/union member lists. Each  item
  275.         of any of  these  lists  may  be input to CDEC as an
  276.         independent declaration later if further translation
  277.         is desired. It is felt that identification  of these
  278.         lists is much more useful than a description of them
  279.         as they can often be very difficult to identify in a
  280.         declaration.  Also the  generated  phrase  would  be
  281.         rather  difficult  to read which  would  defeat  the
  282.         purpose of CDEC.  CDEC also does this identification
  283.         task for initialiser lists.
  284.  
  285.         Quite  difficult-to-understand  declarations  may be
  286.         easily understood with  CDEC's output. For example a
  287.         declaration such as:
  288.  
  289.         struct  basetype  (*root  (int  ival, char *name)) (
  290.         char * buf[10]);
  291.  
  292.         produces  (actual CDEC  output  obtained  using  the
  293.         redirected output feature):
  294.  
  295.  
  296.  
  297.         A Shareware Program       page 5       October, 1990
  298.         CDEC Guide                         For C Programmers
  299.  
  300.  
  301.  
  302.         /* --- CDEC TRANSLATOR ---
  303.         input received:
  304.         struct  basetype  (*root  (int  ival, char *name)) (
  305.         char * buf[10]);
  306.         cdec output:
  307.         "root":  function    (params:  int ival, char *name)
  308.         returning  pointer  to
  309.         function     (params:  char  *  buf[10])   returning
  310.         structure of type basetype
  311.         */
  312.  
  313.  
  314.  
  315.         Be sure to read the  note  programmed  into function
  316.         key F2
  317.  
  318.         Remember CDEC handles <typedef>'s too.
  319.  
  320.  
  321.         6  Shareware users        6  Shareware users
  322.  
  323.  
  324.         Please  note  that  pointers  and  redirected  input
  325.         features  are  only  supported  by   the  registered
  326.         versions of CDEC.
  327.  
  328.         A registered version can be obtained from:
  329.  
  330.         John S. Smith
  331.         c/o 'Rosemont'
  332.         Hawthorn Rd
  333.         Beaufort
  334.         Ebbw Vale
  335.         Gwent
  336.         United Kingdom
  337.  
  338.         The cost is 19 pounds sterling + 2 pounds p&p within
  339.         the U.K. and 3 pounds to other  countries.  For this
  340.         you will receive  the  latest  version  of  CDEC and
  341.         discounts on any upgrades which you will be notified
  342.         about. Please state which version you have now and I
  343.         would appreciate knowing how  you  learned  of CDEC.
  344.         Any constructive comments would also be welcomed.
  345.  
  346.         Please state disc size required, 5.25" or 3.5"
  347.  
  348.  
  349.         7  Disclaimer        7  Disclaimer
  350.  
  351.  
  352.         Although considerable care has gone into the writing
  353.         and testing of this  program,  no  responsibility is
  354.         accepted  for  the results obtained  by  using  this
  355.         program.  Also  no  guarantee  or  warrantee  either
  356.  
  357.  
  358.  
  359.         A Shareware Program       page 6       October, 1990
  360.         CDEC Guide                         For C Programmers
  361.  
  362.  
  363.  
  364.         expressed or  implied is given either to the user of
  365.         the program or  to  any third parties. I reserve the
  366.         right to change the specification,  capabilities and
  367.         charges for CDEC without notice.  In  other  words I
  368.         cannot be bound by old advertising.
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.         A Shareware Program       page 7       October, 1990
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.                            ContentsContents
  433.  
  434.  
  435.                 1  Introduction  . . . . . . . . . .  2
  436.                 2  Installation and Test . . . . . .  2
  437.                 3  Starting CDEC . . . . . . . . . .  3
  438.                 4  Usage . . . . . . . . . . . . . .  3
  439.                 5  Commom omissions and additional
  440.                    information . . . . . . . . . . .  4
  441.                 6  Shareware users . . . . . . . . .  6
  442.                 7  Disclaimer  . . . . . . . . . . .  6
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.                                  i
  484.